Units is a cross-platform computer program for conversion of units of quantities. It has a database of measurement units, including esoteric and historical units. This for instance allows conversion of velocities specified in furlongs per fortnight, and pressures specified in tons per acre. Output units are checked for consistency with the input, allowing verification of conversion of complex expressions.
The original units program has been a standard part of Unix since the early Bell Laboratories versions.[1]
UDUNITS is a similar utility program, except that it has an additional programming library interface and date conversion abilities. UDUNITS is considered the de facto program and library for variable unit conversion for netCDF files.[2]
Contents |
The newer GNU free software version of units (or GNU Units) was written by Adrian Mariano. GNU units includes several extensions to the original version, including
^
' or '**
'.^
' or '**
'.btu + ft lbf
) can be converted.S
to megohm
)./
'), which sometimes required rearrangement of complex expressions; the GNU version allows more natural expressions, such as in the example that follows.sqrt((lbf/inch) / lb)
can be computed.The plain text database units.dat is a good reference in itself, as it is extensively commented and cites numerous sources.
Units will output the result of the conversion in two lines. Usually the first line (multiplication) is the desired result. The second line is the same conversion expressed as a division.
Units can also do math while converting, including several built in mathematical functions such as sin, cos, atan, log, exp, etc.
If you attempt to convert types of measurements that are incompatible units will print a conformability error message and display a reduced form of each measurement.
The examples that follow show results from GNU units version 1.88; GNU units versions 1.84c and earlier defined a furlong in terms of the U.S. survey foot rather than international foot, and will give slightly different results than the examples that involve furlongs.
2526 units, 72 prefixes, 56 nonlinear units You have: 10 furlongs You want: miles * 1.25 / 0.8 You have: 1 gallon + 3 pints You want: quarts * 5.5 / 0.18181818 You have: sqrt(miles^2) Definition: 1609.344 m You have: 21 btu + 6500 ft lbf You want: btu * 29.352939 / 0.034068139 You have:
C:\>units "ten furlongs per fortnight" "kilometers per hour" * 0.0059871429 / 167.02458
% units cup ounces conformability error 0.00023658824 m^3 0.028349523 kg
One form of the Darcy–Weisbach equation for fluid flow is
where ΔP is the pressure drop, ρ is the mass density, f is the (dimensionless) friction factor, L is the length of the pipe, Q is the volumetric flow rate, and d is the pipe diameter. It might be desirable to have the equation in the form
that would accept typical US units; the constant A1 could be determined manually using the unit-factor method, but it could be determined more quickly and easily using units:
$ units "(8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)" psi * 43.533969 / 0.022970568
Crane Technical Paper No. 410,[3] Eq. 3-5, gives the multiplicative value as 43.5.